import pytest
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from duxiaoman import  Test


class Testpreopen(Test):
    @pytest.fixture(params=[("谷歌","http://localhost:90")],scope='function')
    def preopen(self,request):
        driver,url= request.param
        if(driver=='谷歌'):
            driver=webdriver.Chrome()
        else:
            driver = webdriver.Edge()
        driver.get(url)
        driver.maximize_window()
        yield driver
        driver.close()
    @pytest.mark.parametrize("username,password",[("lisi","123456"),("admin","123456")])
    def test_login(self,username,password,preopen):
        self.login(username,password,preopen) ##封装登陆
    @pytest.mark.parametrize("username,password",[("wangermazi","123456")])
    def test_register(self,username,password,preopen):
        self.register(username,password,preopen)
    @pytest.mark.parametrize("username,password,account",[("lisi","123456","12553455")])
    def test_addcarderror(self,username,password,account,preopen):
        self.login(username,password,preopen)
        self.lingmoney(username,password,account,preopen)
    @pytest.mark.parametrize("username,password,blank",[("lisi","123456","建设")])
    def test_addcard(self,username,password,blank,preopen):
        self.login(username,password,preopen)
        self.addcard(blank,preopen)
    @pytest.mark.parametrize("username,password,blank,blankcard",[("lisi","123456","建设","12345671")])
    def test_addcarderror(self,username,password,blank,blankcard,preopen):
        self.login(username,password,preopen)
        self.addcarderror(blank,blankcard,preopen)
    @pytest.mark.parametrize("username,password,blank,blankcard", [("lisi", "123456", "建设", "11111111111111111")])
    def test_addsamecard(self, username, password, blank, blankcard, preopen):
        self.login(username, password, preopen)
        self.addsamecard(blank, blankcard, preopen)
    @pytest.mark.parametrize("username,password",[("lisi","123456")])
    def test_deletecard(self,username,password,preopen):
        self.login(username,password,preopen)
        self.deletecard(preopen)
    @pytest.mark.parametrize("username,password", [("lisi", "123456")])
    def test_deletecard(self, username, password, preopen):
        self.login(username, password, preopen)
        self.deletecardbeetween(preopen)
    @pytest.mark.parametrize("username,password,money,day",[("lisi","123456","12000","300")])
    def test_Onlineloansadd(self,username,password,money,day,preopen):
        self.login(username,password,preopen)
        self.Onlineloansadd(money,day,preopen)










